package com.jy.controller;


import com.jy.common.enums.ResponseWrapper;
import com.jy.common.model.login.BackstageLogin;
import com.jy.common.model.login.LoginByCodeParam;
import com.jy.common.model.login.ReceptionLoginParam;
import com.jy.service.UserService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/login")
public class LoginController {

    private final UserService userService;

    public LoginController(UserService userService) {
        this.userService = userService;
    }

    /**
     * 前台登陆
     */
    @PostMapping("/receptionLogin-with-password")
    public ResponseWrapper receptionLogin(@Validated @RequestBody ReceptionLoginParam param) {
        return userService.receptionLogin(param);
    }

    /**
     * 前台登陆（手机号验证码）
     */
    @PostMapping("/loginByCode")
    public ResponseWrapper loginByCode(@Validated @RequestBody LoginByCodeParam param) {
        return userService.loginByCode(param);
    }


    /**
     * 后台登陆
     */
    @PostMapping("/backstage-login")
    public ResponseWrapper backstageLogin(@Validated @RequestBody BackstageLogin param) {
        return userService.backstageLogin(param);
    }



}
